const Service = require('egg').Service;
class LyService extends Service {
    async fenleitop(page){
        const sql = `select * FROM (user,cook) inner join cook1user on user.id = cook1user.userid  and cook1user.cookid = cook.id WHERE 浏览次数>100  LIMIT ${(page-1)*10} ,10;`;
        const data = await this.app.mysql.query(sql);
        return data;
    } 
    async xinxiu(page){
        const sql = `select * FROM (user,cook) inner join cook1user on user.id = cook1user.userid  and cook1user.cookid = cook.id ORDER BY 浏览次数 desc LIMIT ${(page-1)*10} ,10`;
        const data = await this.app.mysql.query(sql);
        return data;
    }

    async chufang101(page){
        const sql = `select * FROM (user,cook) inner join cook1user on user.id = cook1user.userid  and cook1user.cookid = cook.id ORDER BY score desc LIMIT ${(page-1)*10} ,10`;
        const data = await this.app.mysql.query(sql);
        return data;
    }
    //所有菜品搜索
    async allcaidan(){
        const sql = `select * FROM (user,cook) inner join cook1user on user.id = cook1user.userid  and cook1user.cookid = cook.id `;
        const data = await this.app.mysql.query(sql);
        return data;
    }
    //往期头条
    async wangqitop(page){
        const sql = `select * FROM (user,cook) inner join cook1user on user.id = cook1user.userid  and cook1user.cookid = cook.id ORDER BY pushtime desc LIMIT ${(page-1)*10} ,10`;
        const data = await this.app.mysql.query(sql);
        return data;
    }

    async popcaidan(){
        const sql = `select * FROM (user,cook) inner join cook1user on user.id = cook1user.userid  and cook1user.cookid = cook.id ORDER BY 浏览次数 desc LIMIT 0 ,5`;
        const data = await this.app.mysql.query(sql);
        return data;
    }
    async caishitiaozhuan(zhhid){
        const sql = `SELECT * from zhh WHERE id="${zhhid}"`;
        const data = await this.app.mysql.query(sql);
        return data;
    }
    async  lydishes(type){
        const sql = `SELECT * from zhh WHERE type="${type}"`;
        const data = await this.app.mysql.query(sql);
        return data;
    }
    
}
module.exports = LyService;